package com.signway.module_signway_adapter_Api;

import android.content.Context;
import android.util.Log;

import com.signway.open.api.IOpenPowerApi;
import com.signway.opensdk.interfaces.base.Callback1;
import com.signway.opensdk.internal.command.signway.ApiConst;
import com.signway.opensdk.model.SDKResult;
import com.signway.opensdk.sdk.SDK;
import com.signway.utils.LogHelper;


/*
 * -----------------------------------------------------------------
 * Copyright (C) 2011-2019, by your Signway, All rights reserved.
 * -----------------------------------------------------------------
 *
 * ProjectName: droid5119
 *
 * Author: Administrator
 *
 * Email: pf.wang@Signway.cn
 *
 * Description:
 *
 * -----------------------------------------------------------------
 * 2019-5-29 : Create SignwayPowerApi.java
 * -----------------------------------------------------------------
 */
public class SignwayPowerApi implements IOpenPowerApi {
    private static final String TAG = "SignwayPowerApi";
    private static SignwayPowerApi mSignwayPowerApi;
    private static Context mContext;

    public static synchronized SignwayPowerApi getInstance(Context context) {
        mContext = context;
        if (mSignwayPowerApi == null) {
            mSignwayPowerApi = new SignwayPowerApi(context);
        }
        return mSignwayPowerApi;
    }

    public SignwayPowerApi(Context context) {
        this.mContext = context;
    }

    //重启
    public void reboot() {
        SDK.systemAPI().setAndroidReboot(new Callback1<SDKResult<Boolean>>() {
            @Override
            public void onMsg(SDKResult<Boolean> booleanSDKResult) {
                LogHelper.d("reboot callback ===" + booleanSDKResult.getValid() + "  " + booleanSDKResult.getContent());
            }
        });
    }

    public void setPowerOnTime(long millis) {
        Log.i(TAG, "setPowerOnTime: ");
    }

    public void powerOff() {
        Log.i(TAG, "powerOff: ");
    }

    //休眠
    public void shutDown() {
        Log.i(TAG, "shutDown: ");
        SDK.displayApi().setScreenOnoff(ApiConst.ScreenID.SCREEN_ID_LVDS, false, new Callback1<SDKResult<Boolean>>() {
            @Override
            public void onMsg(SDKResult<Boolean> booleanSDKResult) {
                LogHelper.d("setScreenOnoff lvds callback ===" + booleanSDKResult.getValid() + "  " + booleanSDKResult.getContent());
            }
        });
        SDK.displayApi().setHdmiOnoff(false, new Callback1<SDKResult<Boolean>>() {
            @Override
            public void onMsg(SDKResult<Boolean> booleanSDKResult) {
                LogHelper.d("setScreenOnoff hdmi callback ===" + booleanSDKResult.getValid() + "  " + booleanSDKResult.getContent());
            }
        });
        SDK.systemAPI().setPowerShallowStandby(true, new Callback1<SDKResult<Boolean>>() {
            @Override
            public void onMsg(SDKResult<Boolean> booleanSDKResult) {
                LogHelper.d("setPowerShallowStandby sdk callback ===" + booleanSDKResult.getValid() + "  " + booleanSDKResult.getContent());
            }
        });
    }

}
